<template>
  <div style="background-color: #f5f6f7; width: 960px">
    <div class="baseDiv" >
      <el-form :model="addForm" :rules="rules" ref="addForm"  class="addForm">
        <el-form-item label="入库仓库" prop="storageText">
          <el-select v-if="this.$props.isAdditionalInformation" disabled class="selectclass"  @change="getStorageOtherInfo" v-model="addForm.storageName"  clearable filterable placeholder="请选择仓库">
            <el-option
              v-for="item in this.storageList"
              :key="item.id"
              :label="item.storageName"
              :value="item.storageName">
            </el-option>
          </el-select>
          <el-select v-else class="selectclass" v-model="addForm.storageName"  @change="getStorageOtherInfo"  clearable filterable placeholder="请选择仓库">
            <el-option
              v-for="item in this.storageList"
              :key="item.id"
              :label="item.storageName"
              :value="item.storageName">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="货主企业"  prop="companyText">
          <search-select v-if="this.$props.isAdditionalInformation" v-model="addForm.ownerName" :disabledSelect="true" :url="'/maliwms/company/getCompanySelectList'" :inputValue="this.addForm.ownerName" :disabled="true" style="width: 420px" :params="searchparamsOwner" labelKey="ownerName" @changeSelect="changeInputOwner" valueKey="id"></search-select>
          <search-select v-else style="width: 420px" :inputValue="this.addForm.ownerName" v-model="addForm.ownerName" :queryParam="queryParamOwner" queryKey="companyName" :url="'/maliwms/company/getCompanySelectList'" :params="searchparamsOwner" labelKey="companyName" @changeSelect="changeInputOwner" valueKey="id"></search-select>
        </el-form-item>
        <el-form-item label="联系人姓名" prop="contact">
            <el-input v-model="addForm.contactName" placeholder="请输入联系人姓名" clearable></el-input>
        </el-form-item>
        <el-form-item label="联系人电话" prop="contactPhone">
            <el-input v-model="addForm.contactPhone" placeholder="请输入联系人电话" clearable></el-input>
        </el-form-item>
        <el-form-item label="司机姓名"  prop="driverName">
            <el-input v-model="addForm.driverName" placeholder="请输入司机姓名" clearable></el-input>
        </el-form-item>
        <el-form-item label="司机电话"  prop="driverPhone">
            <el-input v-model="addForm.driverPhone" placeholder="请输入司机电话" clearable></el-input>
        </el-form-item>
        <el-form-item label="仓库联系人姓名"  prop="storageContact">
            <el-input v-model="addForm.storageContact" placeholder="请输入联系人姓名" clearable></el-input>
        </el-form-item>
        <el-form-item label="仓库联系人电话"  prop="storageContactPhone">
            <el-input v-model="addForm.storageContactPhone" placeholder="请输入仓库联系人电话" clearable></el-input>
        </el-form-item>
        <el-form-item label="理货人姓名" prop="clerkName">
            <el-input v-model="addForm.clerkName" placeholder="请输入理货人姓名" clearable></el-input>
        </el-form-item>
        <el-form-item label="入库日期"  prop="instoreDate">
            <!--<el-input type="date" v-model="addForm.instoreDate" clearable></el-input>-->
            <el-date-picker v-model="addForm.instoreDate"  type="date" clearable format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="请输入入库日期">
            </el-date-picker>
        </el-form-item>
        <el-form-item label="入库单号" prop="instoreOrderNo">
            <el-input v-model="addForm.instoreOrderNo" placeholder="请输入入库单号" clearable></el-input>
        </el-form-item>
        <el-form-item label="柜号"  prop="cntrNo">
            <el-input v-model="addForm.cntrNo" style="width: 420px" placeholder="请输入柜号" clearable></el-input>
        </el-form-item>
        <div label="" style="width: 970px;" prop="">
            <el-table border :data="this.goodList" style="margin-top: 30px;margin-bottom:10px;margin-left: 20px;width:100%" >
              <el-table-column prop="goodsName" label="货物名称" align="center" v-bind:width="110" style="width:6vw;" >
                <div slot-scope="scope">
                  <el-input size="mini" maxlength="150"  clearable v-model="scope.row.goodsName"></el-input>
                </div>
              </el-table-column>
              <el-table-column prop="vendor" label="生产厂家" align="center" v-bind:width="110" style="width:6vw;" >
                <div slot-scope="scope">
                  <el-input size="mini" maxlength="150" clearable v-model="scope.row.vendor"></el-input>
                </div>
              </el-table-column>
              <el-table-column prop="countryOrigin" label="原产地"align="center" v-bind:width="110" style="width:6vw;" >
                <div slot-scope="scope">
                  <el-input size="mini" maxlength="150" clearable v-model="scope.row.countryOrigin"  ></el-input>
                </div>
              </el-table-column>
              <el-table-column prop="productDate" label="生产日期" align="center" v-bind:width="110" style="width:6vw;" >
                <div slot-scope="scope">
                  <el-date-picker type="date" v-model="scope.row.productDate" clearable format="yyyy-MM" value-format="yyyy-MM"  placeholder="请输入生产日期">
                  </el-date-picker>
                </div>
              </el-table-column>
              <el-table-column prop="planCount" label="计划入库数量" align="center" v-bind:width="110" style="width:12vw;" >
                <div slot-scope="scope">
                  <el-input size="mini" v-model="scope.row.planCount" clearable maxlength="10" @keyup.native="verifyInteger(scope.row, 'planCount')" ></el-input>
                </div>
              </el-table-column>
              <el-table-column prop="actCount" label="实际入库数量" align="center" v-bind:width="110" style="width:12vw;" >
                <div slot-scope="scope">
                  <el-input size="mini" v-model="scope.row.actCount"clearable maxlength="10" @keyup.native="verifyInteger(scope.row, 'actCount')" ></el-input>
                </div>
              </el-table-column>
              <el-table-column  prop="unit" label="单位" align="center" v-bind:width="110">
                <div slot-scope="scope">
                  <el-select v-model="scope.row.unitName" @change="getUnitOtherInfo(scope.row,scope.$index)">
                    <el-option
                      v-for="item in unitArray"
                      :key="item.dictKey"
                      :label="item.dictValue"
                      :value="item.dictValue">
                    </el-option>
                  </el-select>
                </div>
              </el-table-column>

              <el-table-column prop="planWeight" label="计划入库重量(kg)" align="center" v-bind:width="110" style="width:12vw;" >
                <div slot-scope="scope">
                  <el-input size="mini" v-model="scope.row.planWeight" maxlength="10" clearable @keyup.native="verifyDecimal(scope.row, 'planWeight')" ></el-input>
                </div>
              </el-table-column>

              <el-table-column prop="actWeight" label="实际入库重量(kg)" align="center" v-bind:width="110" style="width:12vw;" >
                <div slot-scope="scope">
                  <el-input size="mini" v-model="scope.row.actWeight" maxlength="10" clearable @keyup.native="verifyDecimal(scope.row, 'actWeight')" ></el-input>
                </div>
              </el-table-column>
              <el-table-column  prop="packageId" label="包装" align="center" v-bind:width="110">
                <div slot-scope="scope">
                  <el-select v-model="scope.row.packageName" @change="getPackageInfo(scope.row,scope.$index)">
                    <el-option
                      v-for="item in packageArray"
                      :key="item.dictKey"
                      :label="item.dictValue"
                      :value="item.dictValue">
                    </el-option>
                  </el-select>
                </div>
              </el-table-column>

              <el-table-column prop="remark" label="唛头照片">
                <div slot-scope="scope">
                  <el-button type="primary"  plain  @click="editMaitou(scope.$index)">编辑</el-button>
                </div>
              </el-table-column>

              <el-table-column prop="remark" label="抽检照片(选填)">
                <div slot-scope="scope">
                  <el-button  type="primary" plain   @click="editChouJian(scope.$index)">编辑</el-button>
                </div>
              </el-table-column>

              <el-table-column fixed="right"  label="操作">
                <div slot-scope="scope">
                  <el-button v-if="scope.$index == 0" @click.native.prevent="addRow(scope.$index,goodList)" type="text" class="icon maliiconfont maliicon-img_details_add icon_right" size="small">  </el-button>
                  <el-button v-else @click.native.prevent="deleteRow(scope.$index, goodList)" type="text"  class="icon maliiconfont maliicon-img_details_subtract icon_right" size="small">  </el-button>
                </div>
              </el-table-column>
            </el-table>
        </div>
      </el-form>
      <file-upload :roleType="this.$props.roleType" :headTitle="'提交入库录单资料'" :fileUrlsArray="this.responseData" :headSonTitle="'支持pdf,jpg,png,gif,bmp,xls,xlsx,csv,doc,docx (最多选择5张)'" @getFileUrls="getFileUrls" ></file-upload>
      <input-com :headTitle="'货主备注(选填)'" :inputValue="this.addForm.ownerRemark"  @getInputVal="getInputOwnerVal" :headSonTitle="'填写备注'"></input-com>
      <input-com :headTitle="'客服备注(选填)'" :inputValue="this.addForm.customerRemark"  @getInputVal="getInputCustomerVal" :headSonTitle="'填写备注'"></input-com>
      <el-row class="btnFrameClass">
        <el-button class="singleBtnClass" @click="saveInstore(1)" type="primary" plain>保存</el-button>
        <el-button class="singleBtnClass" @click="saveInstore(2)" type="primary">提交</el-button>
      </el-row>
    </div>
    <pc-dialog :is-show="isShowEditPicDialog"  title ='编辑唛头照片' @on-close="isShowEditPicDialog = false">
        <edit-pic :headTitle="'提交唛头照片'" :fileUrlsArray="this.fileUrlMaitouArray" :headSonTitle="'支持pdf,jpg,png,gif,bmp (最多选择1张)'" @closeEditPic="closeEditPic" @getFileUrls="getFileUrls">
        </edit-pic>
    </pc-dialog>
    <pc-dialog :is-show="isShowEditPicChoujianDialog"  title ='编辑抽检照片' @on-close="isShowEditPicChoujianDialog = false">
        <edit-pic :headTitle="'提交抽检照片'" :fileUrlsArray="this.fileUrlChoujianArray" :headSonTitle="'支持pdf,jpg,png,gif,bmp (最多选择5张)'" @closeEditPic="closeEditPic" @getFileUrls="getFileUrls">
        </edit-pic>
    </pc-dialog>
  </div>
</template>
<script>
  import maValidate from 'utils/common-method/validate/index';
  import inputCom from 'components/input/baseTitleInput.vue';
  import fileUpload from 'components/fileUpload/file.vue';
  import editPic from '../instoreAdd/editPicture.vue';
  import {validateTips} from 'utils/tips';
  import PcDialog from 'components/dialog';
  import searchSelect from 'components/search-select/searchSelect';
  export default {
    components: {
      editPic,
      inputCom,
      fileUpload,
      PcDialog,
      searchSelect
    },
    props: {
      roleType: {
        type: Number
      },
      detailId: {
        type: String
      },
      isAdditionalInformation: {
        type: Boolean
      }
    },
    data() {
      return {
        isShowEditPicDialog: false,
        fileIndex: 0,  // 唛头抽检 位于表格第几行
        fileUrlMaitouArray: [], // 唛头照片url
        fileUrlChoujianArray: [], // 抽检照片url
        instoreFiles: [], // 入库单数组
        scanFiles: [], // 抄码单数组
        declarationFiles: [], // 报关单数组
        inspectionFiles: [], // 商检单数组
        batchFiles: [], // 生产批次单数组
        isShowEditPicChoujianDialog: false,
        storageList: [], // 下拉搜索仓库
        goodList: [{
          goodsName: '',
          vendor: '',
          countryOrigin: '',
          productDate: '',
          planCount: null,
          actCount: null,
          unit: '',
          unitName: '',
          planWeight: null,
          actWeight: null,
          packageId: '',
          packageName: '',
          markImg: [],
          checkImg: []
        }],
        unitArray: [],
        packageArray: [],
        responseData: {
          batchFiles: [
          ],  // 生产批次单数组
          businessType: '',
          clerkName: '',
          cntrNo: '',
          customerRemark: '',
          declarationFiles: [
          ], // 报关单数组
          driverName: '',
          driverPhone: '',
          findOrderNo: '',
          id: null,
          inspectionFiles: [],  // 商检单数组
          instoreDate: '',
          instoreDetails: [
            {
              actCount: null,
              actWeight: null,
              checkImg: [],
              countryOrigin: '',
              goodsName: '',
              id: null,
              markImg: [],
              packageId: '',
              packageName: '',
              planCount: null,
              planWeight: null,
              productDate: '',
              unit: '',
              unitName: '',
              vendor: ''
            }
          ],
          instoreFiles: [], // 入库单数组
          instoreOrderNo: '',
          ownerId: null,
          storageName: '',
          ownerName: '',
          contactName: '',
          contactPhone: '',
          storageContact: '',
          storageContactPhone: '',
          ownerRemark: '',
          resource: '',
          scanFiles: [], // 抄码单数组
          status: null,
          storageId: null
        },
        addForm: {
          storageName: '',
          ownerName: '',
          contactName: '',
          contactPhone: '',
          driverName: '',
          driverPhone: '',
          storageContact: '',
          storageContactPhone: '',
          clerkName: '',
          instoreDate: '',
          instoreOrderNo: '',
          cntrNo: '',
          ownerRemark: '',
          customerRemark: ''
        },
        rules: {
          storageText: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 150, message: validateTips.WORD_LESS_150, trigger: 'blur'}
          ],
          companyText: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 150, message: validateTips.WORD_LESS_150, trigger: 'blur'}
          ],
          contactName: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 150, message: validateTips.WORD_LESS_150, trigger: 'blur'}
          ],
          contactPhone: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {validator: maValidate.checkMobileNo, trigger: 'blur'}
          ],
          driverName: [
            {required: false, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 150, message: validateTips.WORD_LESS_150, trigger: 'blur'}
          ],
          driverPhone: [
            {required: false, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {validator: maValidate.checkMobileNoFalse, trigger: 'blur'}
          ],
          storageContact: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 150, message: validateTips.WORD_LESS_150, trigger: 'blur'}
          ],
          clerkName: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 150, message: validateTips.WORD_LESS_150, trigger: 'blur'}
          ],
          storageContactPhone: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {validator: maValidate.checkMobileNo, trigger: 'blur'}
          ],
          instoreDate: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'}
          ],
          instoreOrderNo: [
            {required: true, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 20, message: validateTips.LESS_20, trigger: 'blur'}
          ],
          cntrNo: [
            {required: false, message: validateTips.NOT_EMPTY, trigger: 'blur'},
            {min: 0, max: 20, message: validateTips.LESS_20, trigger: 'blur'}
          ]
        },
        queryParamStorage: { // 搜索数据参数
          storageName: '',
          pageNum: 1,
          pageSize: 100
        },
        queryParamOwner: { // 搜索数据参数
          companyName: ''
        },
        searchparamsStorage: [
          {
            title: '入库仓库',
            key: 'storageName',
            style: 'float: left; width: 15rem; color: #8492a6; font-size: 13px'
          },
          {
            title: '联系人姓名',
            key: 'storageContactName',
            style: 'float: left; width: 30rem; color: #8492a6; font-size: 13px'
          },
          {
            title: '联系人电话',
            key: 'storageContactPhone',
            style: 'float: left; width: 30rem; color: #8492a6; font-size: 13px'
          }
        ],
        searchparamsOwner: [
          {
            title: '公司名称',
            key: 'companyName',
            style: 'float: left; width: 30rem; color: #8492a6; font-size: 13px'
          },
          {
            title: '联系人',
            key: 'contactName',
            style: 'float: left; width: 30rem; color: #8492a6; font-size: 13px'
          },
          {
            title: '联系人电话',
            key: 'contactPhone',
            style: 'float: left; width: 15rem; color: #8492a6; font-size: 13px'
          }
        ]
      };
    },
    created() {
      this.getUnitInfo(); // 获取单位包装
      this.getStorageInfo(); // 获取仓库数据
      this.getTableDataInfo(); // 获取详情数据 填入补充资料
    },
    methods: {
      getUnitInfo() {
        let valueStr = '?keys=' + ['wms_unit', 'wms_package'];
        this.ajax({
          type: 'GET',
          url: '/maliwms/dict/getDictByKeyArray' + valueStr,
          loading: true,
          success: (res) => {
            setTimeout(() => {
              this.$pcNProgress.done();
            }, 300);
            this.unitArray = res.result.wms_unit;
            this.packageArray = res.result.wms_package;
          }
        });
      },
      getStorageInfo() {
        // let valueStr = JSON.stringify(['wms_unit', 'wms_package']);
        this.ajax({
          type: 'POST',
          url: '/maliwms/storage/selectStorage',
          data: {storageName: ''},
          loading: true,
          success: (res) => {
            setTimeout(() => {
              this.$pcNProgress.done();
            }, 300);
            this.storageList = res.result;
          }
        });
      },
      getTableDataInfo() {
        if (this.$props.isAdditionalInformation) {
          this.ajax({
            type: 'GET',
            url: '/maliwms/instore/instoreDetail/' + this.$props.detailId,
            loading: true,
            success: (res) => {
              setTimeout(() => {
                this.$pcNProgress.done();
              }, 300);
              this.responseData = res.result;
              this.goodList = this.responseData.instoreDetails;
              this.addForm = this.responseData;
              for (let i = 0; i < this.responseData.instoreDetails.length; i++) {
                if (this.responseData.instoreDetails[i].goodsName === '-') {
                  this.responseData.instoreDetails[i].goodsName = '';
                }
                if (this.responseData.instoreDetails[i].actCount === '-') {
                  this.responseData.instoreDetails[i].actCount = '';
                }
                if (this.responseData.instoreDetails[i].actWeight === '-') {
                  this.responseData.instoreDetails[i].actWeight = '';
                }
                if (this.responseData.instoreDetails[i].productDate === '-') {
                  this.responseData.instoreDetails[i].productDate = '';
                }
                if (this.responseData.instoreDetails[i].planCount === '-') {
                  this.responseData.instoreDetails[i].planCount = '';
                }
                if (this.responseData.instoreDetails[i].planWeight === '-') {
                  this.responseData.instoreDetails[i].planWeight = '';
                }
                if (this.responseData.instoreDetails[i].unitName === '-') {
                  this.responseData.instoreDetails[i].unitName = '';
                }
                if (this.responseData.instoreDetails[i].packageName === '-') {
                  this.responseData.instoreDetails[i].packageName = '';
                }
                if (this.responseData.instoreDetails[i].vendor === '-') {
                  this.responseData.instoreDetails[i].vendor = '';
                }
                if (this.responseData.instoreDetails[i].countryOrigin === '-') {
                  this.responseData.instoreDetails[i].countryOrigin = '';
                }
              }
            }
          });
        }
      },
      // 校验整数
      verifyInteger(val, prop) {
        maValidate.verifyInteger(val, prop);
      },
      // 校验小数
      verifyDecimal(val, prop) {
        maValidate.verifyDecimal(val, prop);
      },
      // 关闭唛头抽检编辑
      closeEditPic() {
        this.isShowEditPicDialog = false;
        this.isShowEditPicChoujianDialog = false;
      },
      // 获取单位其他信息
      getUnitOtherInfo: function(value, rowindex) {
        for (let j = 0; j < this.unitArray.length; j++) {
          if (this.unitArray[j].dictValue === value.unitName) {
            this.goodList[rowindex].unit = this.unitArray[j].dictKey;
          }
        }
      },
      // 获取包装信息
      getPackageInfo: function(value, rowindex) {
        for (let j = 0; j < this.packageArray.length; j++) {
          if (this.packageArray[j].dictValue === value.packageName) {
            this.goodList[rowindex].packageId = this.packageArray[j].dictKey;
          }
        }
      },
      // 下拉搜索仓库选择
      getStorageOtherInfo: function(value) {
        for (let j = 0; j < this.storageList.length; j++) {
          if (this.storageList[j].storageName === value) {
            this.addForm.storageContact = this.storageList[j].applicantContact;
            this.addForm.storageContactPhone = this.storageList[j].applicantConTel;
            this.responseData.storageId = this.storageList[j].id;
          }
        }
      },
      // 下拉搜索货主选择
      changeInputOwner(val) {
        this.addForm.ownerName = val.companyName;
        this.addForm.contactName = val.contactName;
        this.addForm.contactPhone = val.contactPhone;
        this.responseData.ownerId = val.id;
      },
      getFileUrls(titleImg, fileNameArr, fileUrlArr) {
        if (titleImg === '唛头照片') {
          this.goodList[this.fileIndex].markImg = [];
          for (let i = 0; i < fileUrlArr.length; i++) {
            let singleImg = {name: '', url: ''};
            singleImg.name = fileNameArr[i];
            singleImg.url = fileUrlArr[i];
            this.goodList[this.fileIndex].markImg.push(singleImg);
          }
        }
        if (titleImg === '抽检照片') {
          this.goodList[this.fileIndex].checkImg = [];
          for (let i = 0; i < fileUrlArr.length; i++) {
            let singleImg = {name: '', url: ''};
            singleImg.name = fileNameArr[i];
            singleImg.url = fileUrlArr[i];
            this.goodList[this.fileIndex].checkImg.push(singleImg);
          }
        }
        if (titleImg === '入库单') {
          this.responseData.instoreFiles = [];
          for (let i = 0; i < fileUrlArr.length; i++) {
            let singleImg = {name: '', url: ''};
            singleImg.name = fileNameArr[i];
            singleImg.url = fileUrlArr[i];
            this.responseData.instoreFiles.push(singleImg);
          }
        }
        if (titleImg === '抄码单') {
          this.responseData.scanFiles = [];
          for (let i = 0; i < fileUrlArr.length; i++) {
            let singleImg = {name: '', url: ''};
            singleImg.name = fileNameArr[i];
            singleImg.url = fileUrlArr[i];
            this.responseData.scanFiles.push(singleImg);
          }
        }
        if (titleImg === '报关单') {
          this.responseData.declarationFiles = [];
          for (let i = 0; i < fileUrlArr.length; i++) {
            let singleImg = {name: '', url: ''};
            singleImg.name = fileNameArr[i];
            singleImg.url = fileUrlArr[i];
            this.responseData.declarationFiles.push(singleImg);
          }
        }
        if (titleImg === '商检单') {
          this.responseData.inspectionFiles = [];
          for (let i = 0; i < fileUrlArr.length; i++) {
            let singleImg = {name: '', url: ''};
            singleImg.name = fileNameArr[i];
            singleImg.url = fileUrlArr[i];
            this.responseData.inspectionFiles.push(singleImg);
          }
        }
        if (titleImg === '生产批次单') {
          this.responseData.batchFiles = [];
          for (let i = 0; i < fileUrlArr.length; i++) {
            let singleImg = {name: '', url: ''};
            singleImg.name = fileNameArr[i];
            singleImg.url = fileUrlArr[i];
            this.responseData.batchFiles.push(singleImg);
          }
        }
      },
      getInputOwnerVal(val) {
        this.addForm.ownerRemark = val;
      },
      getInputCustomerVal(val) {
        this.addForm.customerRemark = val;
      },
      deleteRow(index, rows) {
        rows.splice(index, 1);
      },

      addRow(index, tableData, event) {
        tableData.push({
          goodsName: '',
          vendor: '',
          countryOrigin: '',
          productDate: '',
          planCount: '',
          actCount: '',
          unit: '',
          unitName: '',
          planWeight: '',
          actWeight: '',
          packageId: '',
          packageName: '',
          markImg: [],
          checkImg: []
        });
      },
      editMaitou(rowIndex) {
        this.fileIndex = rowIndex;
        this.fileUrlMaitouArray = this.goodList[rowIndex].markImg;
        this.isShowEditPicDialog = true;
        this.isShowEditPicChoujianDialog = false;
      },
      editChouJian(rowIndex) {
        this.fileIndex = rowIndex;
        this.fileUrlChoujianArray = this.goodList[rowIndex].checkImg;
        this.isShowEditPicChoujianDialog = true;
        this.isShowEditPicDialog = false;
      },
      removeOtherPara (urlArray) {  // 移除url 数组 多出来的 uid status字段
        if (urlArray.length > 0) {
          for (let i = 0; i < urlArray.length; i++) {
            if (urlArray[i].uid !== '') {
              delete urlArray[i].uid;
            }
            if (urlArray[i].status !== '') {
              delete urlArray[i].status;
            }
          }
        }
      },
      saveInstore(operateType) {
        if (this.$props.isAdditionalInformation) {
          this.responseData.businessType = 2; // 补充资料
        } else {
          this.responseData.businessType = 1; // 入库录单
        }
        if (operateType === 1) {
          this.responseData.operateType = 1; // 保存
        } else {
          this.responseData.operateType = 2; // 提交
        }
        this.responseData.storageName = this.addForm.storageName;
        this.responseData.ownerName = this.addForm.ownerName;
        this.responseData.clerkName = this.addForm.clerkName;
        this.responseData.driverName = this.addForm.driverName;
        this.responseData.driverPhone = this.addForm.driverPhone;
        this.responseData.contactName = this.addForm.contactName;
        this.responseData.contactPhone = this.addForm.contactPhone;
        this.responseData.storageContact = this.addForm.storageContact;
        this.responseData.storageContactPhone = this.addForm.storageContactPhone;
        this.responseData.instoreDate = this.addForm.instoreDate;
        this.responseData.instoreOrderNo = this.addForm.instoreOrderNo;
        this.responseData.cntrNo = this.addForm.cntrNo;
        this.responseData.ownerRemark = this.addForm.ownerRemark;
        this.responseData.customerRemark = this.addForm.customerRemark;
        this.responseData.instoreDetails = this.goodList;
        this.responseData.id = this.$props.detailId;
        this.removeOtherPara(this.responseData.instoreFiles);
        this.removeOtherPara(this.responseData.scanFiles);
        this.removeOtherPara(this.responseData.declarationFiles);
        this.removeOtherPara(this.responseData.inspectionFiles);
        this.removeOtherPara(this.responseData.batchFiles);
        this.responseData.resource = 3; // 1.找库订单  2.移动端指令 3.入库录单 4.PC端指令
        if (operateType === 2) {
          if ((this.addForm.storageName === '' || !this.addForm.storageName) || (this.addForm.ownerName === '' || !this.addForm.ownerName) || this.addForm.contactName === '' || this.addForm.contactPhone === '' || this.addForm.storageContact === '' || this.addForm.storageContactPhone === '' || this.addForm.clerkName === '' || this.addForm.instoreDate === '' || this.addForm.instoreOrderNo === '') {
            this.$pcMessage.error('基础信息不完整，请检查！');
            return false;
          } else {
            let onceMessag = 0; // 只弹提示一次
            for (let i = 0; i < this.goodList.length; i++) {
              if ((this.goodList[i].goodsName === '') || (this.goodList[i].vendor === '') || (this.goodList[i].countryOrigin === '') || (this.goodList[i].productDate === '') || (this.goodList[i].planCount === '') || (this.goodList[i].actCount === '') || (this.goodList[i].unitName === '') || (this.goodList[i].planWeight === '') || (this.goodList[i].actWeight === '') || (this.goodList[i].packageName === '')) {
                if (onceMessag === 0) {
                  this.$pcMessage.error('请完善货物信息！');
                  onceMessag++;
                }
              } else if ((this.goodList[i].markImg.length === 0)) {
                if (onceMessag === 0) {
                  this.$pcMessage.error('货物缺少一张唛头照片！');
                  onceMessag++;
                }
              } else {
                if (this.responseData.instoreFiles.length === 0) {
                  this.$pcMessage.error('请上传仓库入库单照片！');
                  return false;
                } else {
                  this.ajax({
                    type: 'POST',
                    url: '/maliwms/instore/saveInstore',
                    data: this.responseData,
                    loading: true,
                    success: (res) => {
                      setTimeout(() => {
                        this.$pcNProgress.done();
                      }, 300);
                      this.$emit('closeRefresh');
                    }
                  });
                }
              }
            }
          }
        } else {
          if ((this.addForm.storageName === '' || !this.addForm.storageName) || (this.addForm.ownerName === '' || !this.addForm.ownerName)) {
            this.$pcMessage.error('请选择入库仓库和货主企业！');
            return false;
          } else {
            console.log('this.responseData======,', this.responseData);
            this.ajax({
              type: 'POST',
              url: '/maliwms/instore/saveInstore',
              data: this.responseData,
              loading: true,
              success: (res) => {
                setTimeout(() => {
                  this.$pcNProgress.done();
                }, 300);
                this.$emit('closeRefresh');
              }
            });
          }
        }
      }
    }
  };
</script>
<style scoped>
  .baseDiv {
    display: flex;
    flex-wrap: wrap;
    width: 960px;
    height: 520px;
    border: 1px solid #e5e5e5;
    background-color: white
  }

  .baseDiv .el-form-item {
    display: inline-block;
    width: 420px;
    margin-left: 50px;
  }

  .baseDiv .el-form-item .el-input {
    width: 420px;
  }

  .addForm{
    margin-top:10px;
    margin-left: -30px;
    /*width:1000px;*/
  }
  .btnFrameClass
  {
    margin-left: 350px;
    margin-top: 40px;
    margin-bottom: 20px;
  }
  .singleBtnClass
  {
    width: 140px;
    height: 40px;
  }
 .selectclass {
   width: 35rem;
 }
</style>
